package com.wangyk.rabbitmqconsole.controller;

import com.wangyk.rabbitmqcommon.model.console.User;
import com.wangyk.rabbitmqconsole.message.StreamClient;
import com.wangyk.rabbitmqconsole.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("/stream")
public class StreamMessageController
{
    @Autowired
    private StreamClient streamClient;

    @Autowired
    private UserService userService;

    @RequestMapping("/stream.do")
    @ResponseBody
    public String process()
    {
        User user = userService.selectUserById(1);
        /**
         * 发送端
         * */
        streamClient.messageChannel().send(MessageBuilder.withPayload(user).build());
        return "test";
    }
}
